package com.jdk.demo.thread.completableFuture;

import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

public class RunAfterEitherDemo {

	public static void main(String[] args) throws InterruptedException {
		CompletableFuture<String> future1 = CompletableFuture.supplyAsync(new Supplier<String>() {
	        @Override
	        public String get() {
	            return "hello1";
	        }
	    });
	    CompletableFuture<String> future2 = CompletableFuture.supplyAsync(new Supplier<String>() {
	        @Override
	        public String get() {
	            return "hello2";
	        }
	    });
	    future1.runAfterEither(future2, new Runnable() {
	        @Override
	        public void run() {
	            System.out.println("上面有一个已经完成了。");
	        }
	    });
	    Thread.sleep(1000000000);
	}

}
